package com.qd.common.sys.domain.entity.org;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author sjk
 * 组织机
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class OrgDTO extends BaseQuery {
    /**
     * 主键
     */
    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "组织机构";

    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "机构ID"})
    @ColumnWidth(35)
    @NotBlank(message = "机构ID不能为空", groups = {UpdateGroup.class})
    @Size(max = 50, message = "机构ID长度不能超过{max}位", groups = {DefaultGroup.class, UpdateGroup.class})
    private String orgId;
    /**
     * 父级机构ID
     */
    @ExcelProperty(value = {EXCEL_TITLE, "父级机构ID"})
    @ColumnWidth(35)
    @Size(max = 50, message = "父级机构ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String parentId;
    /**
     * 父级机构ID显示值
     */
    @ExcelIgnore
    private String parentIdDisplay;
    /**
     * 机构名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "*机构名称"})
    @ColumnWidth(35)
    @NotBlank(message = "机构名称不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "机构名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgName;
    /**
     * 机构状态:0正常 1停用
     */
    @ExcelIgnore
    @NotNull(message = "机构状态不能为空", groups = DefaultGroup.class)
    private Integer orgStatus;
    /**
     * 机构状态显示值
     */
    @ExcelProperty(value = {EXCEL_TITLE, "*机构状态"})
    private String orgStatusDisplay;
    /**
     * 显示顺序
     */
    @ExcelProperty(value = {EXCEL_TITLE, "显示顺序"})
    private Integer orderNum;
    /**
     * 负责人
     */
    @ExcelProperty(value = {EXCEL_TITLE, "负责人"})
    @Size(max = 50, message = "负责人长度不能超过{max}位", groups = DefaultGroup.class)
    private String leader;
    /**
     * 联系人
     */
    @ExcelProperty(value = {EXCEL_TITLE, "联系人"})
    @Size(max = 50, message = "联系人长度不能超过{max}位", groups = DefaultGroup.class)
    private String contacts;
    /**
     * 联系人电话
     */
    @ExcelProperty(value = {EXCEL_TITLE, "联系人电话"})
    @Size(max = 20, message = "联系人电话长度不能超过{max}位", groups = DefaultGroup.class)
    private String contactsPhone;
    /**
     * 邮箱
     */
    @ExcelProperty(value = {EXCEL_TITLE, "邮箱"})
    @Size(max = 50, message = "邮箱长度不能超过{max}位", groups = DefaultGroup.class)
    private String email;
    /**
     * 网址
     */
    @ExcelProperty(value = {EXCEL_TITLE, "网址"})
    @Size(max = 50, message = "网址长度不能超过{max}位", groups = DefaultGroup.class)
    private String website;
    /**
     * 地址
     */
    @ExcelProperty(value = {EXCEL_TITLE, "地址"})
    @Size(max = 100, message = "地址长度不能超过{max}位", groups = DefaultGroup.class)
    private String address;
    /**
     * 介绍
     */
    @ExcelProperty(value = {EXCEL_TITLE, "介绍"})
    @Size(max = 500, message = "介绍长度不能超过{max}位", groups = DefaultGroup.class)
    private String remark;
    /**
     * 添加时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "添加时间"})
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "更新时间"})
    private LocalDateTime updateTime;
    /**
     * 机构子集
     */
    @ExcelIgnore
    private List<OrgDTO> children;

    @JsonIgnore
    @ExcelIgnore
    private int distance;

    @Override
    public void freeData() {
        this.orgId = null;
        this.parentId = null;
        this.parentIdDisplay = null;
        this.orgName = null;
        this.orderNum = null;
        this.leader = null;
        this.contacts = null;
        this.contactsPhone = null;
        this.email = null;
        this.website = null;
        this.address = null;
        this.remark = null;
        this.orgStatus = null;
        this.orgStatusDisplay = null;
        this.addTime = null;
        this.updateTime = null;
        if (null != children) {
            children.clear();
        }
        super.freeData();
    }
}
